from requests.auth import HTTPBasicAuth
import requests

# url = 'http://127.0.0.1:8000/auth-token/'
# headers = {'Accept': 'application/json'}
# data={'username':'admin', 'password':'admin'}
# # req = requests.get(url, headers=headers, auth=auth)

# req = requests.post(url, data=data)
# print(req.json())

# url = 'http://127.0.0.1:8000/frontend/test/'
# # auth = HTTPBasicAuth('Authorization', 'Token c6ff42554de5e04b5ba20b1c11c7787874374647')
# headers = {'Accept': 'application/json', 'Authorization':'Token c6ff42554de5e04b5ba20b1c11c7787874374647'}
# headers = {'Accept': 'application/json'}
# req = requests.get(url, headers=headers)
# print(req.text)


req = requests.post(
            # "http://localhost:8000/api/User/getToken/",
            "https://efmiddlewaredev.tslj.com.cn/middleware/api/User/getToken",
            json={
                # "username": "FGRAPI",
                # "password": "123456",
                "userName": 'FGRAPI',
                "password": '123456',

            },
            headers={'Content-Type':'application/json-patch+json'}
        )

print(req.json()['data'])

token='Bearer '+req.json()['data']


url="https://efmiddlewaredev.tslj.com.cn/middleware/api/ewo_staff/loginEOrder"

req = requests.post(
    # "http://localhost:8000/api/User/getToken/",
    url,
    json={
        # "username": "FGRAPI",
        # "password": "123456",
        "staffId": 'GNS001',
        "pwd": '123456',

    },
    headers={'Content-Type':'application/json-patch+json', 'Authorization':token}
)

res=req.json()
print(req.json())





